<?php
require_once ("function.php"); 
ob_start(); 
	session_start(); 
$is_Logged = checkLoggedin();

	require_once '../services/VehicleService.php';
	require_once '../services/model/dao/vo/PartnerVO.php';
$error = '';
//$who = $_SESSION["gdadminid"];

	if(isset($_POST['submit'])){
	$_instance = new VehicleService();
	$partnerVO = new PartnerVO();
	
	if($_POST['username'] == ''){
		$partnerVO->username = uniqid("p");
	}else{
		$partnerVO->username = $_POST['username'];
	}
	$partnerVO->password = $_POST['password'];
	if($_POST['f_name'] == ''){
		$partnerVO->f_name = 'Unknown';
	}else{
		$partnerVO->f_name = $_POST['f_name'];
	}
	if($_POST['l_name'] == ''){
		$partnerVO->l_name = 'Unknown';
	}else{
		$partnerVO->l_name = $_POST['l_name'];
	}
	if($_POST['company'] == ''){
		$partnerVO->company = 'Unknown';
	}else{
		$partnerVO->company = $_POST['company'];
	}
	$partnerVO->zip_code = ($_POST['zip'])?$_POST['zip']:0;
	$partnerVO->phone_no = ($_POST['c_phone'])?$_POST['c_phone']:0;
	$partnerVO->email = $_POST['email'];
	$partnerVO->sec_email = $_POST['s_email'];
	$partnerVO->address = $_POST['address'];
	$partnerVO->country = $_POST['country'];
	$partnerVO->city = $_POST['city'];
	$partnerVO->latitude = ($_POST['latitude'])?$_POST['atitude']:0;
	$partnerVO->longitude = ($_POST['longitude'])?$_POST['longitude']:0;

	$partnerVO->who_added = 0;
	
	$result = $_instance->createNewPartner($partnerVO);
$error = "";
	if($result)
{
	$error = "New Partner added successfully";

}else{
	$error = "E-mail/Username already Exist.";
}

	
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- saved from url=(0048)file:///C:/wamp/www/Autogator/autogator_bid.html -->
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Vehicle's Bid Informations</title>
<link href="css/mainpartner.css" rel="stylesheet" type="text/css"></link>
<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-21110030-5']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
 function confirmWindow()
 {
	if ( document.form.password.value == "" )
    {
        alert ( "Please fill in the 'Password' box." );
        return false;
    }
	if ( document.form.password.value != document.form.cpass.value )
    {
        alert ( "Password and Confirm Passord are not match" );
        return false;
    }
    
    if ( document.form.city.value == "" )
    {
        alert ( "Please fill in the 'City' box." );
        return false;
    }
	
	if ( document.form.email.value == "")
    {
        alert ( "Please fill in the 'E- mail' box." );
        return false;
    }
	else
	{
		var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		if(reg.test(document.form.email.value))
		{
			return true;
		}
		else
		{
			alert ( "Please enter a valid 'E-mail' address." );
			return false;
		}
	}
 }

</script>

<style type="text/css">
.required {
	color: #F00;
}
</style>
</head>
<body>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/987792179/?value=1.00&amp;label=e3VDCI2dgAMQs4aC1wM&amp;guid=ON&amp;script=0"/>
</div>
</noscript>
<div class="boxBlack">
<div class="boxBlackTl"><div class="boxBlackTr">
  <h2>Autogator Partner Manager</h2>
  <?php 
  if($is_Logged)
  echo "<div align='right'><a href = 'partner.php?do=login'>Logout</a></div>";
  ?>
</div></div>
<div class="boxBodyBlack">
  <div class="boxLblue floatLeft" style="width:100%;">
  <div class="boxLblueTl"><div class="boxLblueTr">
    <h2>Add New Partner</h2>
  </div></div>
<div class="boxBodyLblue">
<?php
if (!$is_Logged) 
{ 
	 echo "<div>You are not logged in - <A href = \"partner.php\">login</A></div>";
}
else
{
?>
<div><?php echo $error; ?></div>

<form action="" method="post" enctype="multipart/form-data" name="form"  onsubmit="return confirmWindow();">
<div style="padding:10px 10px 10px 10px; border:1px #CCC solid; width:400px">

	<div id="window_list">
	  <div id="item">
    	<div id="img">First Name</div>
        <div id="data">
          <input type="input" name="f_name" id="f_name" class="textbox" value=""/>
        </div>
        
    </div>
     <div id="item">
    	<div id="img">Last Name</div>
        <div id="data">
          <input type="input" name="l_name" id="l_name" class="textbox" value=""/>
        </div>
        
    </div>
    <div id="item"> 
    	<div id="img">User Name</div>
        <div id="data">
          <input type="input" name="username" id="username" class="textbox" value=""/>
        </div>
      
	</div>
    <div id="item">
    	<div id="img">Password<span class="required">*</span></div>
        <div id="data">
          <input type="password" name="password" id="password" class="textbox" value=""/>
        </div>
        
    </div>
     <div id="item">
    	<div id="img">Confirm Password</div>
        <div id="data">
          <input type="password" name="cpass" id="cpass" class="textbox" value=""/>
        </div>
         
    </div>
     <div id="item">
    	<div id="img">Company Name</div>
        <div id="data">
          <input type="input" name="company" id="company" class="textbox" value=""/>
        </div>
        
    </div>
     
     <div id="item">
    	<div id="img">Contact Number</div>
        <div id="data">
          <input type="input" name="c_phone" id="c_phone" class="textbox" value="" size="10" maxlength="10" onkeyup="this.value = this.value.replace(/[^0-9]/, '')"/>
        </div>
        
    </div>
     <div id="item">
    	<div id="img">E - mail<span class="required">*</span></div>
        <div id="data">
          <input type="input" name="email" id="email" class="textbox" value=""/>
        </div>
        
    </div>
     <div id="item">
    	<div id="img">Secondary E - mail</div>
        <div id="data">
          <input type="input" name="s_email" id="s_email" class="textbox" value=""/>
        </div>
        
    </div>
     <div id="item">
    	<div id="img">Address</div>
        <div id="data">
          <input type="input" name="address" id="address" class="textbox" value=""/>
        </div>
        
    </div>
<div id="item">
    	<div id="img">City<span class="required">*</span></div>
        <div id="data">
          <input type="input" name="city" id="city" class="textbox" value=""/>
        </div>
        
    </div>
	<div id="item">
    	<div id="img">Zip Code</div>
        <div id="data">
          <input type="input" name="zip" id="zip" class="textbox" value="" size="10" maxlength="10"/>
        </div>
        
    </div>
     <div id="item">
    	<div id="img">Country</div>
        <div id="data">
          <input type="input" name="country" id="country" class="textbox" value=""/>
        </div>
        
    </div>
     
     <div id="item">
    	<div id="img">Latitude</div>
        <div id="data">
          <input type="input" name="latitude" id="latitude" class="textbox" value="" onkeyup="this.value = this.value.replace(/[^0-9][^.]/, '')"/>
        </div>
        
    </div>
    <div id="item">
    	<div id="img">Longitude</div>
        <div id="data">
          <input type="input" name="longitude" id="longitude" class="textbox" value="" onkeyup="this.value = this.value.replace(/[^0-9]/, '')"/>
        </div>
        
    </div>
    <div id="item">
    	<div id="img">Who Added</div>
        <div id="data">
          <input type="input" name="who_added" disabled="disabled" ="who_added" class="textbox" value=""/>
        </div>
        
    </div>
</div>
<div class="partnerSubmit"><input type="submit"  name="submit" value="Add Partner"/></div>
</div>
</form>
<?php
};
?>
  <div class="clearBoth"></div>
  

</div>
<div class="boxLblueBl"><div class="boxLblueBr"></div></div>
</div>
  <div class="clearBoth"></div>
  <div class="clearBoth"></div>
</div>
<div class="boxBlackBl"><div class="boxBlackBr"></div></div>
</div>
</script>
</body></html>
